package com.jd.controller;


import com.jd.common.AjaxResult;
import com.jd.common.DataGridReq;
import com.jd.common.DataGridResult;
import com.jd.entity.Goods;
import com.jd.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2017/9/19/019.
 */
@RestController
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @PostMapping("list")
    public DataGridResult list(DataGridReq dataGridReq) {
        return goodsService.findAllByReq(dataGridReq);
    }

    @PostMapping("{gid}/delete")
    public AjaxResult delete(@PathVariable Integer gid) {
        return goodsService.delete(gid);
    }

    @PostMapping("add")
    public AjaxResult add(Goods goods){
        return goodsService.save(goods);
    }

    @PostMapping("update")
    public AjaxResult update(@RequestBody Goods goods){
        return goodsService.update(goods);
    }
}
